#!/usr/bin/env python
# -*- coding:utf-8 -*-

from django import forms
from app01 import models

class CreateHost(forms.Form):
    hostid = forms.IntegerField(widget=forms.TextInput(attrs={'placeholder':"Host Id"}))
    hostname = forms.CharField()
    ip = forms.GenericIPAddressField()
    hostgroup_id = forms.IntegerField(widget=forms.Select())
    # business = forms.IntegerField(widget=forms.Select())
    def __init__(self,*args,**kwargs):
        super(CreateHost,self).__init__(*args,**kwargs)
        self.fields['hostgroup_id'].widget.choices = models.HostGroup.objects.all().values_list('id','hostgroup')

class DelHost(forms.Form):
    hostid = forms.IntegerField(widget=forms.TextInput(attrs={'placeholder':"Host Id"}))
    hostname = forms.CharField()
    ip = forms.GenericIPAddressField()

class UpdateHost(forms.Form):
    hostid = forms.IntegerField(widget=forms.TextInput(attrs={'placeholder':"Host Id"}))
    hostname = forms.CharField(required=False)
    ip = forms.GenericIPAddressField(required=False)
    hostgroup_id = forms.IntegerField(required=False,widget=forms.Select())
    # business = forms.IntegerField(widget=forms.Select())
    def __init__(self,*args,**kwargs):
        super(UpdateHost,self).__init__(*args,**kwargs)
        self.fields['hostgroup_id'].widget.choices = models.HostGroup.objects.all().values_list('id','hostgroup')